class Manmal(object):
    pass

class Runnable(object):
    pass

class Dog(Manmal,Runnable):
    pass
# Dog同时拥有Mammal、Runnable的属性和方法。


#__slots__ 限制实例的属性
class Student(object):
    __slots__ = ('name','age') # 用tuple定义允许绑定的属性名称

s = Student()
s.name = 'duan'
s.age = 20
# s.score = 99 # 'Student' object has no attribute 'score' and no __dict__ for setting new attribute

# 使用__slots__要注意，__slots__定义的属性仅对当前类实例起作用，对继承的子类是不起作用的：
class GraduateStudent(Student):
    pass
g = GraduateStudent()
g.score = 9999
print(g)
# 除非在子类中也定义__slots__，这样，子类实例允许定义的属性就是自身的__slots__加上父类的__slots__。


